package jsondemo;

import java.io.InputStream;
import java.util.Properties;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import autoconf.MyAutoConfig;

@SpringBootApplication
@EnableAutoConfiguration(exclude = MyAutoConfig.class)
// MyAutoConfig 在 resources/META-INF/spring.factories 配置
@RestController
public class JsonDemoApp {

    public static void main(String[] args) throws Exception {   
        final String config = "json_demo_app.properties";
        Properties prop = new Properties();
        InputStream inputStream = JsonDemoApp.class.getClassLoader().getResourceAsStream(config);
        prop.load(inputStream);
        SpringApplication application = new SpringApplication(JsonDemoApp.class);
        application.setDefaultProperties(prop);
        application.run(args);
    }
    
    @RequestMapping({"/"})
    public Data data(Data data){
       
        return data;
    }
    
    @RequestMapping({"/data2"})
    public Data data2(@RequestBody Data data){
       
        return data;
    }
    
   
}